<template>
  <div class="app-container">
    <!-- 查询和其他操作 -->
    <!-- <div class="filter-container">
      <el-form :inline="true">
        <el-form-item label="购买时间：">
          <el-date-picker
            v-model="listQuery.value1"
            type="daterange"
            range-separator="-"
            start-placeholder="开始时间"
            end-placeholder="结束时间"/>
        </el-form-item>
        <el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">查找</el-button>
      </el-form>
    </div> -->
    <div>
      <div class="count">
        充值总金额（元）：<span class="num">{{ totalMoney || 0 }}</span>
      </div>
    </div>
    <!-- 查询结果 -->
    <el-table v-loading="listLoading" :data="list" element-loading-text="正在查询中。。。" border fit highlight-current-row >
      <el-table-column align="center" label="商家名称" prop="merchantName" />
   <!--   <el-table-column align="center" label="联系人">
        <template slot-scope="{row}">
          {{ row.userVos?row.userVos[0].phoneNumber:'' }}
        </template>
      </el-table-column> -->
      <el-table-column align="center" label="充值金额" prop="money"/>
      <el-table-column align="center" label="充值时间" prop="createTime"/>
      <el-table-column align="center" label="备注" prop="remark"/>
      <el-table-column align="center" label="操作者" prop="adminUser"/>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.pageSize" @pagination="getList" />

  </div>
</template>

<script>
import { fetchOrderListByBackend, getTotalMoneyByBackend } from './api/index'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination

export default {
  components: { Pagination },
  data() {
    return {
      list: [],
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        pageSize: 20
      },
      totalMoney: 0
    }
  },
  created() {
    this.getList()
    this.getTotalMoney()
  },
  methods: {
    getList() {
      this.listLoading = true
      fetchOrderListByBackend(this.listQuery).then(response => {
        let data = response.data || {}
        this.list = data.list || []
        this.total = Number(data.total || 0)
        this.listLoading = false
      })
    },
    getTotalMoney() {
      getTotalMoneyByBackend(this.listQuery).then(res => {
        this.totalMoney = res.data || 0
      })
    },
    handleFilter(value) {
      this.listQuery.page = 1
      if (value && value[0]) {
        this.listQuery.startTime = value[0]
        this.listQuery.endTime = value[1]
      } else {
        this.listQuery.startTime = null
        this.listQuery.endTime = null
      }
      this.getList()
      this.getTotalMoney()
    }

  }
}
</script>
<style scoped lang="scss">
.count{
  display: inline-block;
  background: rgba(71,141,255,0.12);
  border-radius: 3px 3px 3px 3px;
  border: 1px solid #0061FF;
  font-weight: 350;
  color: #0B0A0A;
  font-size: 12px;
  padding: 6px 15px;
  margin-bottom: 15px;
  .num{
    font-size: 16px;
    color: #0061FF;
  }
}
</style>
